/*
 * @Name: 
 * @Author: LiuCaiLin
 * @Date: 2020-04-16 21:17:36
 * @LastEditors: LiuCaiLin
 * @LastEditTime: 2020-04-23 16:12:37
 */
import {
	request
} from '../../utils/request.js'
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		tablist: ['待付款', '待发货', '待收货', '已发货', '已完成', '售后'],
		active: 0,
		a: 0,
		b: 0,
		c: 0,
		d: 0,
		link: '',
		zizi: ''
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
  globalData: {
    userInfo: null,
    token: '',
    url: 'https://www.lythds.com/'
    // url: 'http://acbkshoptest.com/'
  },
	onLoad: function (options) {
    // 获取用户信息
    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          console.log(res.authSetting['scope.userInfo'])
          // 已经授权，可以直接调用 getUserInfo 获取头像昵称，不会弹框
          wx.getUserInfo({
            success: res => {
              // 可以将 res 发送给后台解码出 unionId
              this.globalData.userInfo = res.userInfo
              console.log(res.userInfo)

              // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
              // 所以此处加入 callback 以防止这种情况
              if (this.userInfoReadyCallback) {
                this.userInfoReadyCallback(res)
              }
            },fail:res=>{
              console.log(res)
            }
          })
        }
        else{
         
          wx.navigateTo({
            url: `/pages/getUserInfo/index`
          })
        }
      }
    })
   
   


	},
	onShow() {
		this.orderNum()

	},
	link() {
		request({
			url: 'link',
		}).then(res => {
			wx.makePhoneCall({
				phoneNumber: res.data.data.link
			})
		})
	},
	toOrderListOne() {
		wx.navigateTo({ url: '/pages/payOne/payOne' });
	},
	toOrderListTwo() {
		wx.navigateTo({ url: '/pages/payTwo/payTwo' });
	},
	toOrderListThree() {
		wx.navigateTo({ url: '/pages/payThree/payThree' });
	},
	toOrderListFour() {
		wx.navigateTo({ url: '/pages/payFour/payFour' });
	},

	orderNum() {
		request({
			url: `orderNumber`,
			token: wx.getStorageSync('token'),
			method: 'POST',
		}).then(res => {
			// console.log('请求总数', res.data.data)
			let datas = res.data.data
			this.setData({
				a: datas[0].num,
				b: datas[1].num,
				c: datas[2].num,
				d: datas[3].num
			})
		})
	},

})
